package com.jsh.erp.datasource.mappers;

import com.jsh.erp.datasource.entities.SysCityCost;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.poi.hpsf.Decimal;

import java.math.BigDecimal;
import java.util.List;

public interface SysCityCostMapper {
    /**
     * 查找所有记录
     * @return
     */
    @Select("select * from sys_city_cost")
    List<SysCityCost> findAllCityCost();

    @Select("select * from sys_city_cost where type = #{type}")
    List<SysCityCost> findCityByType(@Param("type") int type);

    @Select("select * from sys_city_cost where parent_id = #{parentId}")
    List<SysCityCost> findCityByParent(@Param("parentId") Long parentId);

    /**
     * 更新记录
     * @param cityCost
     * @return
     */
    @Update("update sys_city_cost set car_cost = #{city.carCost, jdbcType=DECIMAL}, ship_cost = #{city.shipCost, jdbcType=DECIMAL}, train_cost = #{city.trainCost, jdbcType=DECIMAL} where id = #{city.id}")
    int updateCityCost(@Param("city") SysCityCost cityCost);

    @Select("select * from sys_city_cost where id = #{id}")
    SysCityCost findById(@Param("id") Long id);

    @Select("select * from sys_city_cost where name = #{name} and type = '1'")
    SysCityCost findProvinceByName(@Param("name") String name);

    @Select("select * from sys_city_cost where name = #{name} and type = '2'")
    SysCityCost findCityByName(@Param("name") String name);
}
